Skip to content

Conversation

@IanShaw027
Copy link
Contributor

问题描述

OpenAI 的 usage_limit_reached 错误(实际需要 37 小时重置)被错误地设置为 5 分钟,导致账户在 5 分钟后又被标记为可调度,但实际仍然被限流。

症状:

  • 调度器不断尝试已达配额上限的 OpenAI 账户
  • 每次请求都返回 429 错误
  • 日志显示账户切换 1/10 到 10/10,全部失败

根本原因

handle429 方法只检查 Anthropic 的响应头 anthropic-ratelimit-unified-reset,没有解析 OpenAI 响应体中的 resets_in_seconds 字段。

OpenAI 的 usage_limit_reached 错误格式:

{
  "error": {
    "message": "The usage limit has been reached",
    "type": "usage_limit_reached",
    "resets_at": 1769404154,
    "resets_in_seconds": 133107
  }
}

解决方案

  1. 新增 parseOpenAIRateLimitResetTime 函数解析 OpenAI 响应体
  2. handle429 中优先尝试解析 OpenAI 格式,然后是 Gemini 格式,最后才使用默认 5 分钟
  3. 添加日志记录实际重置时间和剩余时间

影响

  • ✅ 正确处理 OpenAI 的 usage_limit_reached 错误
  • ✅ 避免调度器不断尝试已达配额上限的账户
  • ✅ 兼容 Gemini 和 Antigravity(它们已有正确的处理逻辑)
  • ✅ 保持向后兼容性(Anthropic 仍使用响应头)

@Wei-Shaw
Copy link
Owner

好像重叠了。74e05b8

@Wei-Shaw Wei-Shaw force-pushed the main branch 2 times, most recently from 86fd7d1 to 1245f07 Compare January 26, 2026 01:19
- 问题:OpenAI 的 usage_limit_reached 错误(需 37 小时重置)被错误地设置为 5 分钟
- 原因:handle429 只检查 Anthropic 响应头,没有解析 OpenAI 响应体中的 resets_in_seconds
- 修复:新增 parseOpenAIRateLimitResetTime 函数解析 OpenAI 响应体
- 影响:避免调度器不断尝试已达配额上限的账户
@IanShaw027 IanShaw027 force-pushed the fix/openai-usage-limit-reset-time branch from 1ea8d87 to a55cfeb Compare January 26, 2026 02:04
@Wei-Shaw Wei-Shaw merged commit e32c5f5 into Wei-Shaw:main Jan 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants